package menu

import (
	"context"
	"go-zero-project/services/user/rpc/pb"

	"go-zero-project/services/user/api/internal/svc"
	"go-zero-project/services/user/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteMenuLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDeleteMenuLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteMenuLogic {
	return &DeleteMenuLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DeleteMenuLogic) DeleteMenu(req *types.DeleteMenuReq) error {
	// 1.builder rpc request
	menuReq := pb.DeleteMenuReq{MenuId: req.MenuId}
	// 2.request rpc
	_, err := l.svcCtx.UserCenterClient.DeleteMenu(l.ctx, &menuReq)
	if err != nil {
		return err
	}
	// 3.return obj
	return nil
}
